package Q2;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

public class Threadding extends Thread {

	private Socket socket = null;

	public Threadding(Socket socket) {
		this.socket = socket;
	}

	public void run() {

		try {
			PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
			BufferedReader in = new BufferedReader(new InputStreamReader(socket
					.getInputStream()));

			String inputLine, outputLine;

			while ((inputLine = in.readLine()) != null) {
				System.out.println ("Serveur: " + inputLine);
				inputLine = inputLine.toUpperCase();
	        	out.println(inputLine);
	        	if (inputLine.equals("Bye.")) 
	        		break; 
			}
			out.close();
			in.close();
			socket.close();

		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
